<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('充值卡消费')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-UserCardRecharge-add" th:object="${webUserCardRecharge}">
            <input name="id" id="id" th:value="${webUserCardRecharge.id}" type="hidden" />
            <input name="userId" id="userId"  type="hidden" />
            <input name="params[selectProductId]"  id="selectProductId" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">用户昵称：</label>
                <div class="col-sm-8 form-control-static" th:text="*{nickname}">
                    <input name="userId" th:field="*{userId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">用户姓名：</label>
                <div class="col-sm-8 form-control-static" th:text="*{realname}">
                    <input name="userId" th:field="*{userId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">绑定的门店：</label>
                <div class="col-sm-8 form-control-static" th:text="*{deptName}">
                    <input name="deptId" th:field="*{deptId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">充值卡名称：</label>
                <div class="col-sm-8 form-control-static" th:text="*{name}">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">剩余金额：</label>
                <div class="col-sm-8 form-control-static" th:text="*{money}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">消费金额：</label>
                <div class="col-sm-8">
                    <input name="money" class="form-control number" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">选择商品：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" type="text" name="params[selectProductName]" onclick="selectDeptProduct()" id="selectProductName" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">消费数量：</label>
                <div class="col-sm-8">
                    <input class="form-control number" type="text" name="params[number]" id="number" required>
                </div>
            </div>



            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="params[commend]" class="form-control" placeholder="记录消费了什么产品，原价多少，折扣多少等"></textarea>
                </div>
            </div>

        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />

    <script th:inline="javascript">
        var prefix = ctx + "system/UserCardRecharge"
        $("#form-UserCardRecharge-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/consumption", $('#form-UserCardRecharge-add').serialize());
            }
        }


       function selectDeptProduct(){
            var url = ctx + "system/DeptProduct?type=2";
			$.modal.open("选择商品", url,'1000');
        }
        function doSubmitHandler(id,name){
            $("#selectProductId").val(id);
            $("#selectProductName").val(name);
        }

    </script>
</body>
</html>